home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / dpkg / info / alsa-base.postinst < prev    next >
Encoding:
Text File  |  2009-04-08  |  4.4 KB  |  165 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. MYNAME="$0"
  6.  
  7. # $* message
  8. warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
  9.  
  10. # $* message
  11. report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
  12.  
  13. # Move a conffile without triggering a dpkg question
  14. mv_conffile() {
  15.     OLDCONFFILE="$1"
  16.     NEWCONFFILE="$2"
  17.  
  18.     if [ -e "$OLDCONFFILE" ]; then
  19.         echo "Preserving user changes to $NEWCONFFILE"
  20.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  21.         mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  22.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  23.         rm -f "$OLDCONFFILE".dpkg-bak
  24.     fi
  25. }
  26.  
  27. devfs_is_active()
  28. {
  29.     test -e /dev/.devfsd
  30. }
  31.  
  32. kernel_is_2_6_or_above()
  33. {
  34.     case "$(uname -r)" in
  35.         1.*|2.[012345]*) return 1 ;;
  36.         *) return 0 ;;
  37.     esac
  38. }
  39.  
  40. udev_is_active()
  41. {
  42.     test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
  43.     kernel_is_2_6_or_above || return 1
  44.     return 0
  45. }
  46.  
  47. case "$1" in
  48. configure|reconfigure)
  49.     if dpkg --compare-versions "$2" lt "1.0.10-4ubuntu2"; then
  50.         mv_conffile /etc/modprobe.d/alsa-base-blacklist \
  51.             /etc/modprobe.d/blacklist-modem.conf
  52.  
  53.         rmdir /etc/alsa/modprobe-post-install.d 2>/dev/null || true
  54.         
  55.         rm -f /etc/discover.d/alsa-base
  56.         rmdir /etc/discover.d 2>/dev/null || true
  57.  
  58.         rm -f /etc/hotplug/blacklist.d/alsa-base
  59.         rmdir /etc/hotplug/blacklist.d 2>/dev/null || true
  60.  
  61.         rm -f /etc/modutils/alsa-base
  62.         rmdir /etc/modutils 2>/dev/null || true
  63.  
  64.         rm -f /etc/init.d/alsa
  65.     fi
  66.     if dpkg --compare-versions "$2" lt "1.0.18.dfsg-1ubuntu5"; then
  67.         mv_conffile /etc/modprobe.d/alsa-base \
  68.                 /etc/modprobe.d/alsa-base.conf
  69.         mv_conffile /etc/modprobe.d/blacklist-modem \
  70.                 /etc/modprobe.d/blacklist-modem.conf
  71.     fi
  72.  
  73.     # Remove old obsolete configuration files
  74.     # (Keep this until etch)
  75.     if [ -d /etc/sound ]; then 
  76.         rmdir /etc/sound 2> /dev/null || :
  77.     fi
  78.     rm -f \
  79.         /etc/apm/event.d/alsa \
  80.         /etc/apm/event.d/alsa.dpkg-old \
  81.         /etc/default/alsa.debconf-backup \
  82.         /etc/devfs/conf.d/alsa \
  83.         /etc/discover.conf.d/10alsa \
  84.         /etc/discover.conf.d/10alsa.dpkg-old \
  85.         /etc/discover.conf.d/10linux-sound-base \
  86.         /etc/discover.d/alsa \
  87.         /etc/discover.d/alsa-base \
  88.         /etc/discover.d/linux-sound-base_noOSS \
  89.         /etc/discover.d/linux-sound-base_noALSA \
  90.         /etc/alsa/alsa-base.conf \
  91.         /etc/alsa/modutils/0.5 \
  92.         /etc/alsa/modutils/0.9 \
  93.         /etc/alsa/modutils/1.0 \
  94.         /etc/alsa/modutils/0.5.debconf-backup \
  95.         /etc/alsa/modutils/0.9.debconf-backup \
  96.         /etc/alsa/modutils/1.0.debconf-backup \
  97.         /etc/alsa/modprobe-post-install.d/alsa-base \
  98.         /etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
  99.         /etc/modutils/alsa \
  100.         /etc/modutils/alsa-path \
  101.         /etc/modprobe.d/sound    \
  102.         /etc/modutils/alsa-base \
  103.         /etc/modutils/alsa-base-blacklist \
  104.         /etc/modutils/linux-sound-base_noOSS \
  105.         /etc/modutils/linux-sound-base_noALSA \
  106.         /etc/modprobe.d/alsa
  107.     # Delete hotplug stuff since it isn't used anymore.
  108.     rm -f \
  109.         /etc/hotplug/blacklist.d/alsa-base.dpkg-old \
  110.         /etc/hotplug/blacklist.d/alsa-base \
  111.         /etc/hotplug/blacklist.d/linux-sound-base_noOSS \
  112.         /etc/hotplug/blacklist.d/linux-sound-base_noALSA
  113.     # Decide which conf file to read
  114.     conf_file=""
  115.     if [ -f /etc/default/alsa ] ; then
  116.         conf_file=/etc/default/alsa
  117.     elif [ -f /usr/share/alsa-base/alsa.default ] ; then
  118.         conf_file=/usr/share/alsa-base/alsa.default
  119.     else
  120.         report_error "No configuration file found"
  121.         exit 1
  122.     fi
  123.     # Read variables from conf file
  124.     force_unload_modules_before_suspend="$( 
  125.         . "$conf_file" >/dev/null 2>&1
  126.         echo "$force_unload_modules_before_suspend"
  127.     )"
  128.     # Write new conf file
  129.     cat /usr/share/alsa-base/alsa.default | sed \
  130.         -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
  131.         > /etc/default/alsa
  132.     # Set up apm symlinks
  133.     [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
  134.     # $1: file to check
  135.     already_linked_to_alsa()
  136.     {
  137.         [ "$1" ] || return 1
  138.         [ -L "$1" ] || return 1
  139.         [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
  140.         return 0
  141.     }
  142.     ALREADY_LINKED=no
  143.     for F in /etc/apm/suspend.d/??alsa ; do
  144.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  145.     done
  146.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
  147.     ALREADY_LINKED=no
  148.     for F in /etc/apm/resume.d/??alsa ; do
  149.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  150.     done
  151.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
  152.     ;;
  153. abort-upgrade|abort-remove|abort-deconfigure)
  154.     # We don't have to do anything because we didn't do anything in prerm
  155.     exit 0
  156.     ;;
  157. *)
  158.     echo "postinst called with unknown argument \`$1'" >&2
  159.     exit 1
  160.     ;;
  161. esac
  162.  
  163.  
  164.  
  165.